<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Spec::Example::Configuration</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Spec::Example::Configuration</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/plugins/rspec/lib/spec/example/configuration_rb.html">
                vendor/plugins/rspec/lib/spec/example/configuration.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000357">after</a>&nbsp;&nbsp;
      <a href="#M000358">append_after</a>&nbsp;&nbsp;
      <a href="#M000354">append_before</a>&nbsp;&nbsp;
      <a href="#M000355">before</a>&nbsp;&nbsp;
      <a href="#M000351">include</a>&nbsp;&nbsp;
      <a href="#M000350">mock_with</a>&nbsp;&nbsp;
      <a href="#M000352">predicate_matchers</a>&nbsp;&nbsp;
      <a href="#M000356">prepend_after</a>&nbsp;&nbsp;
      <a href="#M000353">prepend_before</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000357" class="method-detail">
        <a name="M000357"></a>

        <div class="method-heading">
          <span class="method-name">after</span><span class="method-args">(*args, &amp;proc)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Configuration.html#M000356">prepend_after</a>
</p>
        </div>
      </div>

      <div id="method-M000358" class="method-detail">
        <a name="M000358"></a>

        <div class="method-heading">
          <a href="#M000358" class="method-signature">
          <span class="method-name">append_after</span><span class="method-args">(*args, &amp;proc)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Appends a global <tt><a href="Configuration.html#M000357">after</a></tt>
block to all example groups. See <a
href="Configuration.html#M000354">append_before</a> for filtering
semantics.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000358-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000358-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/example/configuration.rb, line 134</span>
134:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">append_after</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">proc</span>)
135:         <span class="ruby-identifier">scope</span>, <span class="ruby-identifier">options</span> = <span class="ruby-identifier">scope_and_options</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
136:         <span class="ruby-identifier">example_group</span> = <span class="ruby-constant">ExampleGroupFactory</span>.<span class="ruby-identifier">get</span>(
137:           <span class="ruby-identifier">get_type_from_options</span>(<span class="ruby-identifier">options</span>)
138:         )
139:         <span class="ruby-identifier">example_group</span>.<span class="ruby-identifier">append_after</span>(<span class="ruby-identifier">scope</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">proc</span>)
140:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000354" class="method-detail">
        <a name="M000354"></a>

        <div class="method-heading">
          <a href="#M000354" class="method-signature">
          <span class="method-name">append_before</span><span class="method-args">(*args, &amp;proc)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Appends a global <tt><a href="Configuration.html#M000355">before</a></tt>
block to all example groups.
</p>
<p>
If you want to restrict the block to a subset of all the example groups
then specify this in a Hash as the last argument:
</p>
<pre>
  config.prepend_before(:all, :type =&gt; :farm)
</pre>
<p>
or
</p>
<pre>
  config.prepend_before(:type =&gt; :farm)
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000354-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000354-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/example/configuration.rb, line 112</span>
112:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">append_before</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">proc</span>)
113:         <span class="ruby-identifier">scope</span>, <span class="ruby-identifier">options</span> = <span class="ruby-identifier">scope_and_options</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
114:         <span class="ruby-identifier">example_group</span> = <span class="ruby-constant">ExampleGroupFactory</span>.<span class="ruby-identifier">get</span>(
115:           <span class="ruby-identifier">get_type_from_options</span>(<span class="ruby-identifier">options</span>)
116:         )
117:         <span class="ruby-identifier">example_group</span>.<span class="ruby-identifier">append_before</span>(<span class="ruby-identifier">scope</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">proc</span>)
118:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000355" class="method-detail">
        <a name="M000355"></a>

        <div class="method-heading">
          <span class="method-name">before</span><span class="method-args">(*args, &amp;proc)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Configuration.html#M000354">append_before</a>
</p>
        </div>
      </div>

      <div id="method-M000351" class="method-detail">
        <a name="M000351"></a>

        <div class="method-heading">
          <a href="#M000351" class="method-signature">
          <span class="method-name">include(Some::Helpers)<br />
include(Some::Helpers, More::Helpers)<br />
include(My::Helpers, :type => :key)<br />
</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Declares modules to be included in multiple example groups
(<tt>describe</tt> blocks). With no :type, the modules listed will be
included in all example groups. Use :type to restrict the inclusion to a
subset of example groups. The value assigned to :type should be a key that
maps to a class that is either a subclass of <a
href="ExampleGroup.html">Spec::Example::ExampleGroup</a> or extends <a
href="ExampleGroupMethods.html">Spec::Example::ExampleGroupMethods</a> and
includes <a href="ExampleMethods.html">Spec::Example::ExampleMethods</a>
</p>
<pre>
  config.include(My::Pony, My::Horse, :type =&gt; :farm)
</pre>
<p>
Only example groups that have that type will get the modules included:
</p>
<pre>
  describe &quot;Downtown&quot;, :type =&gt; :city do
    # Will *not* get My::Pony and My::Horse included
  end

  describe &quot;Old Mac Donald&quot;, :type =&gt; :farm do
    # *Will* get My::Pony and My::Horse included
  end
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000351-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000351-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/example/configuration.rb, line 69</span>
69:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">include</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
70:         <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> {} <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">Hash</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>
71:         <span class="ruby-identifier">modules</span>, <span class="ruby-identifier">options</span> = <span class="ruby-identifier">args_and_options</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
72:         <span class="ruby-identifier">required_example_group</span> = <span class="ruby-identifier">get_type_from_options</span>(<span class="ruby-identifier">options</span>)
73:         <span class="ruby-identifier">required_example_group</span> = <span class="ruby-identifier">required_example_group</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">required_example_group</span>
74:         <span class="ruby-identifier">modules</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mod</span><span class="ruby-operator">|</span>
75:           <span class="ruby-constant">ExampleGroupFactory</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">required_example_group</span>).<span class="ruby-identifier">send</span>(<span class="ruby-identifier">:include</span>, <span class="ruby-identifier">mod</span>)
76:         <span class="ruby-keyword kw">end</span>
77:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000350" class="method-detail">
        <a name="M000350"></a>

        <div class="method-heading">
          <a href="#M000350" class="method-signature">
          <span class="method-name">mock_with</span><span class="method-args">(mock_framework)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Chooses what mock framework to use. <a href="../Example.html">Example</a>:
</p>
<pre>
  Spec::Runner.configure do |config|
    config.mock_with :rspec, :mocha, :flexmock, or :rr
  end
</pre>
<p>
To use any other mock framework, you&#8216;ll have to provide your own
adapter. This is simply a module that responds to the following methods:
</p>
<pre>
  setup_mocks_for_rspec
  verify_mocks_for_rspec
  teardown_mocks_for_rspec.
</pre>
<p>
These are your hooks into the lifecycle of a given example. RSpec will call
setup_mocks_for_rspec <a href="Configuration.html#M000355">before</a>
running anything else in each <a href="../Example.html">Example</a>. After
executing the <a href="Configuration.html#M000357">after</a> methods, RSpec
will then call verify_mocks_for_rspec and teardown_mocks_for_rspec (this is
guaranteed to run even if there are failures in verify_mocks_for_rspec).
</p>
<p>
Once you&#8216;ve defined this module, you can pass that to <a
href="Configuration.html#M000350">mock_with</a>:
</p>
<pre>
  Spec::Runner.configure do |config|
    config.mock_with MyMockFrameworkAdapter
  end
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000350-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000350-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/example/configuration.rb, line 31</span>
31:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mock_with</span>(<span class="ruby-identifier">mock_framework</span>)
32:         <span class="ruby-ivar">@mock_framework</span> = <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">mock_framework</span>
33:         <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Symbol</span>
34:           <span class="ruby-identifier">mock_framework_path</span>(<span class="ruby-identifier">mock_framework</span>.<span class="ruby-identifier">to_s</span>)
35:         <span class="ruby-keyword kw">else</span>
36:           <span class="ruby-identifier">mock_framework</span>
37:         <span class="ruby-keyword kw">end</span>
38:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000352" class="method-detail">
        <a name="M000352"></a>

        <div class="method-heading">
          <a href="#M000352" class="method-signature">
          <span class="method-name">predicate_matchers</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Defines global predicate matchers. <a href="../Example.html">Example</a>:
</p>
<pre>
  config.predicate_matchers[:swim] = :can_swim?
</pre>
<p>
This makes it possible to say:
</p>
<pre>
  person.should swim # passes if person.can_swim? returns true
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000352-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000352-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/example/configuration.rb, line 87</span>
87:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">predicate_matchers</span>
88:         <span class="ruby-ivar">@predicate_matchers</span> <span class="ruby-operator">||=</span> {}
89:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000356" class="method-detail">
        <a name="M000356"></a>

        <div class="method-heading">
          <a href="#M000356" class="method-signature">
          <span class="method-name">prepend_after</span><span class="method-args">(*args, &amp;proc)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Prepends a global <tt><a href="Configuration.html#M000357">after</a></tt>
block to all example groups. See <a
href="Configuration.html#M000354">append_before</a> for filtering
semantics.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000356-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000356-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/example/configuration.rb, line 123</span>
123:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">prepend_after</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">proc</span>)
124:         <span class="ruby-identifier">scope</span>, <span class="ruby-identifier">options</span> = <span class="ruby-identifier">scope_and_options</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
125:         <span class="ruby-identifier">example_group</span> = <span class="ruby-constant">ExampleGroupFactory</span>.<span class="ruby-identifier">get</span>(
126:           <span class="ruby-identifier">get_type_from_options</span>(<span class="ruby-identifier">options</span>)
127:         )
128:         <span class="ruby-identifier">example_group</span>.<span class="ruby-identifier">prepend_after</span>(<span class="ruby-identifier">scope</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">proc</span>)
129:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000353" class="method-detail">
        <a name="M000353"></a>

        <div class="method-heading">
          <a href="#M000353" class="method-signature">
          <span class="method-name">prepend_before</span><span class="method-args">(*args, &amp;proc)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Prepends a global <tt><a href="Configuration.html#M000355">before</a></tt>
block to all example groups. See <a
href="Configuration.html#M000354">append_before</a> for filtering
semantics.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000353-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000353-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/example/configuration.rb, line 93</span>
93:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">prepend_before</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">proc</span>)
94:         <span class="ruby-identifier">scope</span>, <span class="ruby-identifier">options</span> = <span class="ruby-identifier">scope_and_options</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
95:         <span class="ruby-identifier">example_group</span> = <span class="ruby-constant">ExampleGroupFactory</span>.<span class="ruby-identifier">get</span>(
96:           <span class="ruby-identifier">get_type_from_options</span>(<span class="ruby-identifier">options</span>)
97:         )
98:         <span class="ruby-identifier">example_group</span>.<span class="ruby-identifier">prepend_before</span>(<span class="ruby-identifier">scope</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">proc</span>)
99:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>